package com.example.xinli.controller;

import com.example.xinli.domain.vo.HuibidanganSubmitVo;
import com.example.xinli.domain.vo.ResponseBean;
import com.example.xinli.domain.vo.ZhengnianlianxiSubmitVo;
import com.example.xinli.service.IHuibidanganService;
import com.example.xinli.service.IZhengnianlianxiService;
import com.example.xinli.utils.TokenUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@Slf4j
@RequestMapping("/huibidangan")
public class HuibidanganController {

    @Autowired
    private IHuibidanganService huibidanganService;

    // 获取用户的自动思维列表
    @RequestMapping("/getAllUserHuibidangan")
    @ResponseBody
    public ResponseBean getAllUserHuibidangan(HttpServletRequest request) {
        String token = request.getHeader("Authorization");
        token = token.split(" ")[1];
        String userId = TokenUtil.getId(token);
        return huibidanganService.getAllUserHuibidangan(userId);
    }

    // 上传自动思维
    @RequestMapping("/submitHuibidangan")
    @ResponseBody
    public ResponseBean submitHuibidangan(HttpServletRequest request, @RequestBody HuibidanganSubmitVo huibidanganSubmitVo) {
        return huibidanganService.submitHuibidangan(huibidanganSubmitVo);
    }
}

